from lib.webui.TeacherOp import top
from lib.api.Teacher import tm
from hytest import GSTORE, STEP, INFO, CHECK_POINT
from config.cfg import *


class TeacherWeb1:
    name = "老师登录 - tc005001"

    def teststeps(self):
        STEP(1, "添加老师")

        classid = GSTORE['七一班-id']

        ret = tm.add_teacher(username='sun', realname='孙老师', subjectid=SUBJECT_ID_JUNIOR_MATH,
                             classlist=str(classid), phonenumber="1234567", email="sunan@163.com", idcardnumber="123123")
        retAdd = ret.json()

        CHECK_POINT("添加老师检查", retAdd['retcode'] == 0)

        self.teacherid = retAdd['id']

        STEP(2, "老师登录web界面")

        top.teacherLogin(username='sun', password='888888')
        infos = top.getTeaHomePageInfo()

        INFO(infos)

        expected = ['白月学院00002', '孙老师', '初中数学', '0', '0', '0']

        CHECK_POINT('老师首页信息检查', infos == expected)

    def teardown(self):
        tm.delete_teacher(self.teacherid)
